package com.hrp.hrpdao;

import com.hrp.domain.Jxkhzq;
import com.hrp.domain.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/8/8 0008.
 */
@Mapper
public interface JxkhzqDao {

    @Select("select * from JX_KHZQ")
    List<Jxkhzq> getAllKhzq();

    @Select("select top 24 * from JX_KHZQ")
    List<Jxkhzq> getTopKhzq();

    @Select("select count(*) total from JX_KHZQ")
    Integer getTotalCount();

    //@Select("select * from ( select id,[zqdm],[zqmc],[kssj],[jssj],[memo],[zxzt],[zqyear],[zqmonth],[zqday], Row_Number() OVER (ORDER BY id) row from JX_KHZQ ) T where row > ${startIndex} and row < ${endIndex}")
    //@Select("select top ${pageSize} * from JX_KHZQ where id not in (select top (${pageSize} * (${page} -1)) id from JX_KHZQ)")
    @Select("<script>"
               + " select * from ( select id,[zqdm],[zqmc],[kssj],[jssj],[memo],[zxzt],[zqyear],[zqmonth],[zqday], Row_Number() OVER (ORDER BY id) row from JX_KHZQ ) T where row in "
               + "<foreach item='item' index='index' collection='strList' open='(' separator=',' close=')'>"
                   + "#{item}"
               + "</foreach>"
           + "</script>")
    List<Jxkhzq> getJxkhzqByPage(@Param("strList") List<Integer> strList);


    @Insert("insert into JX_KHZQ(zqdm,zqmc,kssj,jssj,memo,zxzt,zqyear,zqmonth,zqday) values(#{zqdm},#{zqmc},#{kssj},#{jssj},#{memo},0,#{zqyear},#{zqmonth},#{zqday})")
    Integer saveKhzqData(Jxkhzq jxkhzq);


    @Options(statementType=StatementType.CALLABLE)
    @Select({ "exec init_khzq #{zqid}" })
    Integer excutingzq(Map<String,Integer> params);

}
